<include file="Public:header" />
<style>
	.disyc{display:none;}
</style>
<script>
	$(function(){
		//页面加载完毕后开始执行的事件
		$("select[id='api_type']").change(function(){
			if ($(this).val()=="eth") {
				$("#erc_token").show();
				$("#eth_wallet").html('总钱包地址 :');
				$("#eth_account").html('总钱包平台账户 :');
			} else {
				$("#erc_token").hide();
				$("#eth_wallet").html('钱包服务器用户名 :');
				$("#eth_account").html('钱包服务器密码 :');
			}
		});
		$("select[id='token_type']").change(function(){
			if ($(this).val()=="1") {
				$("#erc_token_hy").show();
			} else {
				$("#erc_token_hy").hide();
			}
		});
	});
</script>
<div id="main-content">
	<div id="top-alert" class="fixed alert alert-error" style="display: none;">
		<button class="close fixed" style="margin-top: 4px;">&times;</button>
		<div class="alert-content">警告内容</div>
	</div>
  <div id="main" class="main">
    <div class="main-title-h"> 
    	<span class="h1-title"><a href="{:U('Config/coin')}">币种配置</a> &gt;&gt;</span> 
    	<span class="h1-title"><empty name="data">新增币种<else/>编辑币种</empty></span>
	</div>
    <div class="tab-wrap">
      <div class="tab-content">
        <form id="form" action="{:U('Config/coinEdit')}" method="post" class="form-horizontal" enctype="multipart/form-data">
          <div id="tab" class="tab-pane in tab">
            <div class="form-item cf">
              <table>
                <tr class="controls">
					<td class="item-label">图标 :</td>
					<td>
						<div id="addpicContainer"> 
						<!-- 利用multiple="multiple"属性实现添加多图功能 --> 
						<!-- position: absolute;left: 10px;top: 5px;只针对本用例将input隐至图片底下。--> 
						<!-- height:0;width:0;z-index: -1;是为了隐藏input，因为Chrome下不能使用display:none，否则无法添加文件 --> 
						<!-- onclick="getElementById('inputfile').click()" 点击图片时则点击添加文件按钮 -->
						<notempty name="data.img"> 
							<!--没有图片显示默认图片--> 
							<img id="up_img" onclick="getElementById('inputfile').click()" style="cursor:pointer;max-width:100px;" title="点击添加图片" alt="点击添加图片" src="/Upload/coin/{$data.img}">
						<else/>
							<!--没有图片显示默认图片--> 
							<img id="up_img" onclick="getElementById('inputfile').click()" style="cursor:pointer;max-width:100px;" title="点击添加图片" alt="点击添加图片" src="__PUBLIC__/Admin/images/addimg.png"> 
						</notempty>
						<input type="hidden" id="img" name="img" value="{$data.img}">
						<input type="file" id="inputfile" style="height:0;width:0;z-index:-1;position:absolute;left:10px;top:5px;" value=""/>
						</div>
					</td>
					<td class="item-note">80px*80px</td>
                </tr>
                
                <tr class="controls">
					<td class="item-label">币种简称 :</td>
					<empty name="data['name']">
						<td><input type="text" class="form-control input-10x" name="name" value=""></td>
					<else/>
						<input type="hidden" class="form-control input-10x" name="name" value="{$data.name}">
						<td>{$data.name}</td>
					</empty>
					<td class="item-note">* 币种代码，必须填写：只能英文小写，但不能填写关键字比如：asc 、desc</td>
                </tr>
                <tr class="controls">
					<td class="item-label">英文名称 :</td>
					<td><input type="text" class="form-control input-10x" name="js_yw" value="{$data['js_yw']}"></td>
					<td class="item-note">* 必须填写</td>
                </tr>
                <tr class="controls">
					<td class="item-label">中文名称 :</td>
					<td><input type="text" class="form-control input-10x" name="title" value="{$data['title']}"></td>
					<td class="item-note">* 必须填写</td>
                </tr>
                <tr class="controls">
					<td class="item-label">币种类型:</td>
					<td>
						<select name="type" class="form-control input-10x">
							<option value="qbb" <eq name="data.type" value="qbb">selected</eq>>钱包币</option>
							<option value="ptb" <eq name="data.type" value="ptb">selected</eq>>平台币</option>
							<option value="rgb" <eq name="data.type" value="rgb">selected</eq>>认购币</option>
							<option value="rmb" <eq name="data.type" value="rmb">selected</eq>>法定货币</option>
						</select>
					</td>
					<td class="item-note"></td>
                </tr>
                
                <tr class="controls">
                  <td class="item-label">接口类型 :</td>
					<td>
						<select name="api_type" id="api_type" class="input-small" style="width:120px">
							<option value="" <eq name="data['api_type']" value="">selected</eq>>空设置</option>
							<option value="btc" <eq name="data['api_type']" value="btc">selected</eq>>BTC</option>
							<option value="eth" <eq name="data['api_type']" value="eth">selected</eq>>ETH</option>
						</select>
					</td>
               		<td class="item-note">如果非平台或法定货币，必须选择</td>
                </tr>
                <tr class="controls disyc" id="erc_token" <eq name="data['api_type']" value="eth">style="display:table-row;"</eq>>
					<td class="item-label">是否ERC20 :</td>
					<td>
						<select name="token_type" id="token_type" class="input-small" style="width: 120px">
							<option value="0" <eq name="data['token_type']" value="0">selected</eq>>否</option>
							<option value="1" <eq name="data['token_type']" value="1">selected</eq>>是</option>
						</select>
					</td>
               		<td class="item-note">以太坊发行的代币协议</td>
                </tr>
                <tr class="controls disyc" id="erc_token_hy" <eq name="data['token_type']" value="1">style="display:table-row;"</eq>>
					<td class="item-label">ERC20合约地址 :</td>
					<td><input type="text" class="form-control input-10x" name="dj_hydz" value="{$data['dj_hydz']}" autocomplete="off" aria-autocomplete="none"></td>
					<td class="item-note">非ETH (ERC20) 不用填写</td>
                </tr>
                
                <tr class="controls" style="border-top:1px solid #d0d0d0;">
					<td class="item-label">钱包服务器ip :</td>
					<td><input type="text" class="form-control input-10x" name="dj_zj" value="{$data['dj_zj']}"></td>
					<td class="item-note">对接钱包使用 认购币类型的 不用填写</td>
                </tr>
                <tr class="controls">
					<td class="item-label">钱包服务器端口 :</td>
					<td><input type="text" class="form-control input-10x" name="dj_dk" value="{$data['dj_dk']}"></td>
					<td class="item-note">对接钱包使用 认购币类型的 不用填写</td>
                </tr>
                <tr class="controls">
					<td class="item-label" id="eth_wallet">
						<eq name="data['api_type']" value="eth">总钱包地址 :<else/>钱包服务器用户名 :</eq>
					</td>
					<td><input type="text" class="form-control input-10x" name="dj_yh" value="{$data['dj_yh']}" autocomplete="off" aria-autocomplete="none"></td>
					<td class="item-note">对接钱包使用 认购币类型的 不用填写</td>
                </tr>
                <tr class="controls">
					<td class="item-label" id="eth_account">
						<eq name="data['api_type']" value="eth">总钱包平台账户 :<else/>钱包服务器密码 :</eq>
					</td>
					<td>
						<input type="text" class="form-control input-10x" name="dj_mm" value="{$data['dj_mm']}"  autocomplete="off" aria-autocomplete="none">
					</td>
					<td class="item-note">对接钱包使用 认购币类型的 不用填写</td>
                </tr>

                <tr class="controls" style="border-top:1px solid #d0d0d0;">
					<td class="item-label">兑换方式 :</td>
					<td>
						<select name="change" class="input-small" style="width:120px">
							<option value="0" <eq name="data['change']" value="0">selected</eq>>禁止兑换</option>
							<option value="1" <eq name="data['change']" value="1">selected</eq>>固定比例</option>
							<option value="2" <eq name="data['change']" value="2">selected</eq>>浮动比例</option>
						</select>
					</td>
               		<td class="item-note"></td>
                </tr>
                <tr class="controls">
					<td class="item-label">可兑换币种 :</td>
					<td>
						<select name="changecoin" class="form-control input-10x">
							<volist name="C['coin']" id="v" key="k"> 
								<!-- <option value="{$v['name']}">{$v['title']}</option> --> 
								<option value="{$v['name']}" <eq name="data.changecoin" value="$v['name']">selected</eq>>
									{$v['title']}
								</option>
							</volist>
						</select>
                    </td>
                </tr>
                <tr class="controls">
					<td class="item-label">固定比例 :</td>
					<td><input type="text" class="form-control" name="huilv" value="{$data['huilv']}" autocomplete="off" aria-autocomplete="none"></td>
					<td class="item-note">如填10,则10{$data['title']}兑换1&nbsp;{$data['changecoin']}(选择固定比例时有效)</td>
                </tr>
                <tr class="controls">
					<td class="item-label">最小兑换数量 :</td>
					<td><input type="text" class="form-control" name="amount" value="{$data['amount']}" autocomplete="off" aria-autocomplete="none"></td>
					<td class="item-note">如填10,则最少用10{$data['title']}起兑换{$data['changecoin']}</td>
                </tr>
                <tr class="controls" style="display:none">
					<td class="item-label">转入赠送 :</td>
					<td><input type="text" class="form-control input-10x" name="zr_zs" value="{$data['zr_zs']}"></td>
					<td class="item-note">% (填写0.01-100 任意数字) 转入手续费比例,费用直接从官方手续费地址扣取</td>
                </tr>
                <tr class="controls">
					<td class="item-label">转入状态 :</td>
					<td>
						<select name="zr_jz" class="form-control input-10x" >
							<option value="1" <eq name="data['zr_jz']" value="1">selected</eq>>正常转入</option>
							<option value="0" <eq name="data['zr_jz']" value="0">selected</eq>>禁止转入</option>
						</select>
					</td>
					<td class="item-note"></td>
                </tr>
                <tr class="controls">
					<td class="item-label">一代赠送比例 :</td>
					<td><input type="text" class="form-control input-10x" name="type1_give" value="{$data['type1_give']}"></td>
					<td class="item-note">% 根据单笔计算</td>
                </tr>
                <tr class="controls">
					<td class="item-label">二代赠送比例 :</td>
					<td><input type="text" class="form-control input-10x" name="type2_give" value="{$data['type2_give']}"></td>
					<td class="item-note">% 根据单笔计算</td>
                </tr>
                <tr class="controls">
					<td class="item-label">三代赠送比例 :</td>
					<td><input type="text" class="form-control input-10x" name="type3_give" value="{$data['type3_give']}"></td>
					<td class="item-note">% 根据单笔计算</td>
                </tr>
                <tr class="controls">
					<td class="item-label">确认次数 :</td>
					<td>
						<empty name="data['zr_dz']">
							<input type="text" class="form-control input-10x" name="zr_dz" value="1">
						<else />
							<input type="text" class="form-control input-10x" name="zr_dz" value="{$data['zr_dz']}">
						</empty>
					</td>
					<td class="item-note">转出确认次数必须填写,且大于0</td>
                </tr>
                
                <tr class="controls" style="border-top:1px solid #d0d0d0;">
					<td class="item-label">转出手续费 :</td>
					<td><input type="text" class="form-control input-10x" name="zc_fee" value="{$data['zc_fee']}"></td>
					<td class="item-note">% (填写0.01-100 任意数字) 转出手续费比例,费用直接存入官方手续费地址</td>
                </tr>
                <empty name="data['name']">
					<tr class="controls">
						<td class="item-label">官方手续费地址 :</td>
						<td><input type="text" class="form-control input-10x" name="zc_user" value="0" readonly></td>
						<td class="item-note"><b>[新增币种不可操作]</b> 如果要收取手续费,添加成功后复制官方某账户对应本币地址,重新编辑本币种,填写到本处即可</td>
					</tr>
				<else/>
					<tr class="controls">
						<td class="item-label">官方手续费地址 :</td>
						<td><input type="text" class="form-control input-10x" name="zc_user" value="{$data['zc_user']}"></td>
						<td class="item-note"><b>[重要]</b> 请填写一个官方前台账户生成的本币地址到本处作为手续费(收取|扣除)账户,否则手续费比例设置无效</td>
					</tr>
                </empty>
                <tr class="controls">
                	<td class="item-label">最小转出数量 :</td>
                	<td><input type="text" class="form-control input-10x" name="zc_min" value="{$data['zc_min']}"></td>
                	<td class="item-note">推荐:正数且大于0.01</td>
                </tr>
                <tr class="controls">
                	<td class="item-label">最大转出数量 :</td>
                	<td><input type="text" class="form-control input-10x" name="zc_max" value="{$data['zc_max']}"></td>
                	<td class="item-note">推荐:正数且大于10000</td>
                </tr>
                <tr class="controls">
                	<td class="item-label">转出状态 :</td>
					<td>
						<select name="zc_jz" class="form-control input-10x">
							<option value="1" <eq name="data['zc_jz']" value="1">selected</eq>>正常转出</option>
							<option value="0" <eq name="data['zc_jz']" value="0">selected</eq>>禁止转出</option>
						</select>
					</td>
					<td class="item-note"></td>
                </tr>
                <tr class="controls">
					<td class="item-label">转出自动 :</td>
					<td>
						<empty name="data['zc_zd']">
							<input type="text" class="form-control input-10x" name="zc_zd" value="0">
						<else />
							<input type="text" class="form-control input-10x" name="zc_zd" value="{$data['zc_zd']}">
						</empty>
					</td>
					<td class="item-note">推荐:正数且大于10 (小于这个数自动转出,大于这个数后台审核 )为了安全不要设置太大</td>
                </tr>
                
				<tr class="controls">
					<td class="item-label">排序 :</td>
					<td><input type="text" class="form-control input-10x" name="sort" value="{$data.sort}"></td>
					<td class="item-note"></td>
				</tr>

                <tr class="controls">
					<td class="item-label"></td>
					<td>
						<div class="form-item cf">
							<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">提交</button>
							<a class="btn btn-return" href="{$Think.server.HTTP_REFERER}">返 回</a>
							<notempty name="data.id">
								<input type="hidden" name="id" value="{$data.id}"/>
							</notempty>
						</div>
                    </td>
                </tr>
              </table>
            </div>
          </div>
        </form>
        <script type="text/javascript">
		//提交表单
		$('#submit').click(function () {
			$('#form').submit();
		});
		</script> 
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        //响应文件添加成功事件
        $("#inputfile").change(function () {
            //创建FormData对象
            var data = new FormData();
            //为FormData对象添加数据
            $.each($('#inputfile')[0].files, function (i, file) {
                data.append('upload_file' + i, file);
            });

            //发送数据
            $.ajax({
                url: '/Admin/Config/coinImage',
                type: 'POST',
                data: data,
                cache: false,
                contentType: false, //不可缺参数
                processData: false, //不可缺参数
                success: function (data) {
                    if (data) {
                        $('#up_img').attr("src", '/Upload/coin/' + data);
                        $('#img').val(data);
                        $('#up_img').show();
                    }
                },
                error: function () {
                    alert('上传出错');
                    $(".loading").hide(); //加载失败移除加载图片
                }
            });

        });
    });
</script> 
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor-min.js"></script> 
<script type="text/javascript">
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea', {
            width: '500px',
            height: '100px',
            items: ['source', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'link', 'fullscreen'],
            afterBlur: function () {
                this.sync();
            }
        });
    });
</script> 
   
<include file="Public:footer"/>
<block name="script"> 
<script type="text/javascript" charset="utf-8">
	//导航高亮
	highlight_subnav("{:U('Config/coin')}");
</script>
</block>